#include <iostream>
#include <vector>
#include <map>
#include <list>
#include <queue>
#include <algorithm>
using namespace std;

struct Task {
	int id;
	int etime;
	int ptime;
};
struct cmp {
	bool operator()(const Task& l, const Task& r) {
		if (l.ptime != r.ptime) return l.ptime > r.ptime;
		return l.id > r.id;
	}
};
int main()
{
	int n; cin >> n;
	deque<Task> arr(n);
	for (int i = 0; i < n; ++i) {
		arr[i].id = i;
		cin >> arr[i].etime >> arr[i].ptime;
	}
	sort(arr.begin(), arr.end(), [](auto& l, auto& r) {
		if(l.etime != r .etime) return l.etime < r.etime; 
		return l.id < r.id;
	});

	int curtime = 0;
    priority_queue<Task, vector<Task>, cmp> ready;

    while (!arr.empty() || !ready.empty()) {
        while (!arr.empty() && arr.front().etime <= curtime) {
            ready.push(arr.front());
            arr.pop_front();
        }

        if (!ready.empty()) {
            Task current = ready.top();
            ready.pop();
            cout << current.id << ' ';
            curtime += current.ptime;
        }
        else if (!arr.empty()) {
            curtime = arr.front().etime;
        }
    }

	return 0;
}